package com.ld.cloud.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
@RequestMapping("test")
public class TestController {

    @Autowired
    private RestTemplate restTemplate;
    @Autowired
    private HttpHeaders httpHeaders;

    @RequestMapping("hello")
    public String hello(){
        String result = "";
//        ResponseEntity<String> responseEntity = restTemplate.getForEntity("http://EUREKA-USER-PROVIDER/test/hello",String.class);
//        result = responseEntity.getBody();
//        System.out.println(result);
        result = restTemplate.exchange("http://EUREKA-USER-PROVIDER/test/hello", HttpMethod.GET,new HttpEntity<>(httpHeaders),String.class).getBody();
        return result;
    }
}
